<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/26
 * Time: 9:36
 */

namespace app\validate;


use think\Request;
use think\Validate;

class Member extends Validate
{
    protected $rule =   [

        'name|姓名' => 'require|length:2,4|chs',
        'mobile|手机号'  => 'require|length:11|mobile|unique:member',
        'age|年龄' => 'require|number|between:1,100',
        'captcha|验证码' => 'require|length:6|number',
        'password'   => 'require|length:6,12',
        'repassword|确认密码' => 'require|confirm:password',
        'email' => 'require',
        'id_card|身份证号' => 'require|idCard', //身份证号无需验证长度 直接idCard
        'old_password' => 'require|length:6,12',
        'old_captcha' => 'require|number|length:6',
        'captcha' => 'require|number|length:6',
        'pay_password' => 'require|number|length:6|confirm',
        'old_username'  => 'require|tel',

        'id_number|身份证号' => 'require|length:15,18|alphaNum',
        'phone|手机号' => 'require|tel',
        'driver|驾驶证号' => 'require|unique:member_car',
        'car_number|车牌号' => 'require',
        'car_model|车架号' => 'require',
        'city|城市' => 'require',
        //withdraw_apply提现接口
        'brokerage|提现金额' => 'require|float',
        'withdraw_no|提现账号' => 'require',
        'withdraw_name|提现姓名' => 'require|chs',
        //
        'integral|积分' => 'require|integer'


//        ['phone', 'require|regex:^1[34578]{1}\d{9}$'],
    ];

    protected $message  =   [
        'mobile.require' => '请输入手机号',
        'mobile.length' => '请输入11位手机号',
        'mobile.mobile'     => '请输入正确的手机号',
        'mobile.unique'   => '您的账号已在平台注册过',
        'age.require' => '请输入年龄',
        'age.between' => '请输入1-100之间的数字',
        'city.require' => '请输入城市',
        'id_card.idCard' => '请输入标准的身份证号',
        'password.require' => '密码不能为空',
        'password.length' => '密码请输入6-12位长度字符',
        'repassword.confirm' => '两次密码不一致',

        'captcha.require' => '请输入验证码',
        'captcha.number' => '验证码必须是数字',
        'captcha.length' => '请输入6位验证码',
        'old_password.require' => '原密码不能为空',
        'old_password.length' => '原密码密码请输入6-12位长度字符',
        'pay_password.require' => '支付密码不能为空',
        'pay_password.number' => '支付密码必须为数字',
        'pay_password.length' => '支付密码必须为6位字符长度',
        'pay_password.confirm' => '两次支付密码不一致',
//        'old_username.require' => '原手机号不能为空',
//        'old_username.tel'     => '请输入正确的手机号',
        'old_captcha.require' => '原手机号验证码不能为空',
        'old_captcha.number' => '原手机号验证码必须是数字',
        'old_captcha.length' => '请输入6位原手机号验证码',

        'name.length' => '姓名请输入2-4位字符',
        'id_number.length' => '请输入正确长度的身份证号',
        'id_number.alphaNum' => '身份证只能包含字母和数字',

    ];



    public function sceneLogin()
    {
        return $this->only(['mobile','password'])
            ->remove('mobile','unique')
            ->remove('password','confirm');
    }

    public function sceneRegister()
    {
        return $this->only(['mobile',  'password'])
            ->remove('mobile', 'unique');
    }

//    public function sceneBind_Bank(Request $request)
//    {
//        halt($request);
//    }


//    public function sceneForget_Password()
//    {
//        return $this->only(['mobile', 'captcha', 'password', 'repassword'])->remove('mobile', 'unique');
//    }



//    public function sceneSign_Index(string $name)
//    {
//        return $this->remove(true); // TODO: Change the autogenerated stub
//    }


    protected $scene = [
        'mobile' => ['mobile'=> 'require|tel','captcha'=> 'require|number|length:6'],

        'login'  =>  ['mobile' => 'require|tel','password' => 'require|length:6,12'],

        'web_register_data' => ['username','password' => 'require|length:6,12' ,'captcha' => 'require|number|length:6'],
        'register_mini' => ['username' => 'require|tel','password','password_comfirm','captcha'],
        'forget_password' => ['mobile' => 'require|tel','password' => 'require|length:6,12','captcha'],
        'update_password' => ['captcha','password' => 'require|length:6,12|confirm'], //'username' => 'require|length:6,18',
        'set_pay_password' => ['username' => 'require|tel','captcha','pay_password'],
        'update_username' => ['username','old_captcha','captcha'],
        'withdraw_applys' => ['member_id','brokerage','withdraw_no','withdraw_name'],
        'integral_recharge' => ['member_id','integral']
    ];
}